<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Model;


/**
 * @property int $id
 * @property string $username
 * @property string $password
 * @property string $create_time
 * @property string $update_time
 * @property int $status
 * @property string $ip
 * @property string $ip_location
 * @property string $os
 * @property string $last_login_time
 * @property string $browser
 * @property string $nickname
 * @property string $avatar
 * @property string $mobile
 * @property string $email
 * @property int $sex
 * @property string $login_type
 */
class User extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'user';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'username', 'password', 'create_time', 'update_time', 'status', 'ip', 'ip_location', 'os', 'last_login_time', 'browser', 'nickname', 'avatar', 'mobile', 'email', 'sex', 'login_type'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'status' => 'integer', 'sex' => 'integer'];

    public function roles()
    {
        return $this->belongsToMany(Role::class, 'user_role', 'user_id', 'role_id');
    }
}
